package model.semantics;

import java.util.ArrayList;
import java.util.Collection;

import model.RGBColor;


/**
 * Defines a general method for combining two colors together.
 * 
 * This is primarily a convenience class that provides additional 
 * methods for subclasses to reduce the amount of new code needed
 * to implement an operation.
 * 
 * @author Robert C Duvall
 */
public class InfinaryOperation extends Operation
{
	Collection<Operation> myChildren = new ArrayList<Operation>();
    /**
     * Create a default instance.
     * 
     * Provides default constructor so subclasses do not need to define one.
     */
	
	//TODO: INFINARY - need to update arugment parameter
    protected InfinaryOperation ()
    {
        super(2);
    }
    
    @Override
    protected boolean addChild(Operation o)
    {
    	myChildren.add(o);
    	return true;
    }
    
    protected Collection<Operation> getChildren()
    {
    	return myChildren;
    }


    /**
     * Given any number of colors, combine them to create a single color.
     * 
     * Subclasses must extract array elements.
     */
    @Override
    protected RGBColor evaluateSafely (RGBColor[] colors)
    {
        return evaluateColor(colors);
    }

    /**
    * 
    * There is no reasonable default value to return and this method should not
    * be abstract so throw an exception if neither evaluate method is overridden.
    */
    protected RGBColor evaluateColor (RGBColor[] children)
    {
        throw new UnsupportedOperationException();
    }
}
